package org.mysfit.ctp4j.test;

import java.io.File;
import java.util.Map;

import javax.validation.constraints.NotNull;

import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;

public class MyVelocityTemplateEngine extends VelocityTemplateEngine {

	@Override
    protected void outputCustomFile(@NotNull Map<String, String> customFile, @NotNull TableInfo tableInfo, @NotNull Map<String, Object> objectMap) {
        String entityName = tableInfo.getEntityName();
        String otherPath = this.getPathInfo(OutputFile.other);
        System.out.println(">>>>>>>>>>处理前otherPath=" + otherPath);
		otherPath = otherPath.replace("\\org\\mysfit\\ctp4j\\api\\vo", "//org//mysfit//ctp4j//api//vo");
		System.out.println(">>>>>>>>>>处理后otherPath=" + otherPath);
		for (Map.Entry<String, String> entry : customFile.entrySet()) {
			String fileName = String.format(otherPath + "//" + entityName + "%s", entry.getKey());
            System.out.println(">>>>>>>>>>fileName=" + fileName);
            this.outputFile(new File(fileName), objectMap, entry.getValue());
		}
    }

}
